# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=python-rebulk
pkgver=3.2.0
pkgrel=2
pkgdesc='Define simple search patterns in bulk to perform advanced matching on any string'
arch=('any')
url='https://github.com/Toilal/rebulk'
license=('MIT')
depends=('python')
# python-regex is not a dependency, as it will be deprecated by upstream at some point
makedepends=('git' 'python-setuptools')
checkdepends=('python-pytest')
_commit='ee938ca3c1ce9981a171f8f124271424d6774da9'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python setup.py build
}

check() {
  cd "$pkgname"

  PYTHONPATH="$PWD:$PYTHONPATH" pytest
}

package() {
  cd "$pkgname"

  python setup.py install --root="$pkgdir" --optimize=1

  # delete tests from package
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm -rf "$pkgdir/$site_packages/rebulk/test"

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
